<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page language="java" contentType="text/html;charset=UTF-8"
    pageEncoding="UTF-8"  isELIgnored="false" %>
<%@ include file="./include/head.jsp" %>
<%@ include file="./include/menu_search.jsp" %>
<%@ page import="domain.Product"%>
<%@ page import="java.util.*" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<style>
	p{
		text-align:left;
	}
	.divbookpic p{
		text-align:center;
	}
	.bodydiv{
		background-color:rgb(252, 253, 237);
		padding:20px;
		margin:0 40px;
	}

</style>
</head>
<body >

	<div class="bodydiv">
		<div style="border-style: none none solid none; border-color:#000;border-width:1px;	" ><p>商品目录</p></div>
		<div style="padding:0 10px; border-style: none none solid none; border-color:#000;border-width:1px;	"><p>共${ProductList.size()}件商品</p></div>
		
		<div>
<table  width="100%" cellspacing="0">
	<tr>
<%--		<c:forEach items="${ProductList}" var="p">--%>
<%--			${p.getName()}--%>
<%--		</c:forEach>--%>

		<c:forEach items="${ProductList}" var="p">
			<td>
				<div class="divbookpic">
					<p>
						<img src="/BookStore/client/resources/images/productingImg/product1.jpg" width="115" height="129" border="0"/>
					</p>
				</div>
				<div class="divlisttitle">
					<form action="${pageContext.request.contextPath}/client/Handle-AddCart.jsp" method="post">
						书名:<input type="text" style="border:none" name="PName" value=${p.getName()}  readonly="readonly"/><br/>
						售价:<input type="text" style="border:none" name="Price" value=${p.getPrice()}  readonly="readonly"/><br/>
						库存:<input type="text" style="border:none" name="PNum" value=${p.getPnum()}  readonly="readonly" /><br/>
						<input type="submit" name="book1" value="购买"/>
					</form>
				</div>
			</td>
		</c:forEach>

	</tr>

	
	
	</table>		
		
		
		
		
		</div>
	</div>

	<button type="button"  name="add" value="上" style="margin-left: 50%"
			onclick="up()">
		上一页</button>
	<button type="button" name="add" value="下" style="text-align: center"
			onclick="down()">
		下一页</button>

	<script type="text/javascript">

		function up() {
			let page = <%=session.getAttribute("page")%>;
			let pageSize = <%=session.getAttribute("pageSize")%>
			page = page + 1;
			window.location.href = "${pageContext.request.contextPath}/MenuSearchServlet?text=&page=" + page + "&pageSize=" + pageSize;
		}
		function down() {
			let page = <%=session.getAttribute("page")%>;
			let pageSize = <%=session.getAttribute("pageSize")%>
			page = page - 1 < 0 ? 0 : page - 1;
			window.location.href = "${pageContext.request.contextPath}/MenuSearchServlet?text=&page=" + page + "&pageSize=" + pageSize;
		}
	</script>

</body>
<%@ include file="include/foot.jsp" %>
</html>